package com.ly.cloud.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ly.cloud.dto.SchoolBasicInfoDto;
import com.ly.cloud.entity.SchoolBasicInfoPo;
import com.ly.cloud.exception.mapper.DBException;
import com.ly.cloud.mapper.SchoolBasicInfoMapper;
import com.ly.cloud.service.SchoolBasicInfoService;
import com.ly.cloud.utils.BeanCopyUtils;
import com.ly.cloud.vo.CampusBasicInfoVo;
import com.ly.cloud.vo.SchoolBasicInfoVo;

/** 
 * Class Name: SchoolBasicInfoServiceImpl  
 * Description: 
 * 学校基本信息接口
 * @author: luhuacong
 * @date: 2018年12月12日
 *
 */  
@Service
public class SchoolBasicInfoServiceImpl implements SchoolBasicInfoService {

	@Autowired
	private SchoolBasicInfoMapper schoolBasicInfoMapper;
	
	/** 
	 * Method Name:  getSchoolInfo
	 * Description:  
	 * 获取学校信息
	 * @param id
	 * @return SchoolBasicInfoVo
	 * @author luhuacong
	 * @date: 2018年12月12日
	 */
	@Override
	public SchoolBasicInfoVo getSchoolInfo() {
		try {
			//SchoolBasicInfoPo po = schoolBasicInfoMapper.selectById(id);
			SchoolBasicInfoVo vo = schoolBasicInfoMapper.selectSchoolInfo();
			return vo;
		} catch (Exception e) {
			e.printStackTrace();
			throw new DBException("获取学校信息失败！", e);
		}
	}

	/** 
	 * Method Name:  updateSchoolInfo
	 * Description:  
	 * 修改学校基本信息
	 * @param dto
	 * @return boolean
	 * @author luhuacong
	 * @date: 2018年12月12日
	 */
	@Override
	public boolean updateSchoolInfo(SchoolBasicInfoDto dto) {
		SchoolBasicInfoPo po = BeanCopyUtils.copyBeanProperties(dto, SchoolBasicInfoPo.class);
		try {
			Integer i = schoolBasicInfoMapper.updateById(po);
			if(i>0) {
				return true;
			}else {
				return false;
			}
		} catch (Exception e) {
			throw new DBException("修改学校基本信息失败！", e);
		}
	}

}
